package ar.com.mindset.geometrics.legends {
	import ar.com.mindset.geometrics.ColorEntry;
	import ar.com.mindset.geometrics.RegionsLegend;
	
	import mx.collections.ArrayCollection;
	import mx.formatters.NumberFormatter;

	public class ContinuousListLegend extends ListLegend implements RegionsLegend {

		public function ContinuousListLegend(x:Number=400) {
			super(x);
		}

		protected override function addLegendsToCollection(collection:ArrayCollection, divisions:ArrayCollection, defaultColor:Object):void {
			if (divisions.length > 0) {
				var first:ColorEntry=divisions[0] as ColorEntry;

				var numberFormatter:NumberFormatter=new NumberFormatter();
				numberFormatter.precision=2;
				var formatedKey:String=numberFormatter.format(first.key);

				addSquare(first.color, "< " + formatedKey.toString(), collection);
				for (var i:Number=1; i < divisions.length; i++) {
					var element:ColorEntry=divisions[i] as ColorEntry;
					addSquare(element.color, "> " + formatedKey.toString(), collection);
					formatedKey=numberFormatter.format(element.key);
				}
				addSquare(defaultColor, "> " + formatedKey.toString(), collection);
			}
		}


	}
}